<template>
  <div>
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="card">
      <el-row :gutter="20" class="c2">
        <el-col :span="8">
          <el-input placeholder="请输入内容" v-model="query">
            <el-button
                slot="append"
                icon="el-icon-search"
                @click="order()"
            ></el-button>
          </el-input>
        </el-col>
      </el-row>
      <el-table :data="tableData" stripe border="">
        <el-table-column type="index"> </el-table-column>
        <el-table-column prop="order_number" label="订单编号">
        </el-table-column>
        <el-table-column prop="order_price" label="订单价格" width="80px">
        </el-table-column>
        <el-table-column prop="pay_status" label="是否付款 " width="80px">
          <template #default="{ row }">
            <el-tag type="success" v-if="row.pay_status === '1'">已付款</el-tag>
            <el-tag type="danger" v-else> 未付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货 " width="80px">
        </el-table-column>
        <el-table-column label="创建时间">
          <template #default="{ row }">{{
              moment(row.upd_time).format("YYYY-MM-DD HH:ss:mm")
            }}</template>
        </el-table-column>

        <el-table-column label="操作">
          <template #default="{ row }">
            <el-button
                type="primary"
                icon="el-icon-edit"
                circle
                @click="bianji(row)"
            ></el-button>
            <el-button
                type="success"
                icon="el-icon-map-location"
                circle
                @click="wuliu"
            ></el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-pagination
        class="fooer"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pagenum"
        :page-sizes="[10, 15, 20, 30]"
        :page-size="pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
    >
    </el-pagination>
    <el-dialog title="物流信息" :visible.sync="wuliudialogVisible" width="50%">
      <el-timeline :reverse="reverse">
        <el-timeline-item
            v-for="(activity, index) in activities"
            :key="index"
            :timestamp="activity.timestamp"
        >
          {{ activity.content }}
        </el-timeline-item>
      </el-timeline>
    </el-dialog>
    <el-dialog title="修改订单数据" :visible.sync="dialogVisible" width="50%">
      <el-form
          :model="ruleForm"
          :rules="rules"
          ref="ruleForm"
          label-width="100px"
      >
        <el-form-item label="订单价格" prop="order_price">
          <el-input v-model="ruleForm.order_price" type="number"></el-input>
        </el-form-item>
        <el-form-item label="是否付款" prop="pay_status">
          <el-radio-group v-model="ruleForm.pay_status">
            <el-radio label="已付款"></el-radio>
            <el-radio label="未付款"></el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="是否发货" prop="is_send">
          <el-radio-group v-model="ruleForm.is_send">
            <el-radio label="是"></el-radio>
            <el-radio label="否"></el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm()">立即创建</el-button>
          <el-button @click="resetForm('ruleForm')">重置</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>
getorder
<script>
import moment from "moment";
import { getorderlist, getorderlistapi, getorder } from "@/api/user";
export default {
  name: "OrderS",
  data() {
    return {
      id: "",
      ruleForm: {},
      rules: {},
      moment,
      query: "",
      pagenum: 1,
      pagesize: 10,
      tableData: [],
      total: 0,
      dialogVisible: false,
      //编辑
      wuliudialogVisible: false,
      reverse: true,
      activities: [
        {
          content: "卖家发货",
          timestamp: "2018-05-09 12:25:03",
        },
        {
          content: "您的订单将由HLA（北京海淀区清河中街店）门店安排发货。",
          timestamp: "2018-05-09 12:22:24",
        },
        {
          content: "商品已经下单",
          timestamp: "2018-05-08 21:36:04",
        },

        {
          content:
              "[北京市]北京海淀育新小区营业点派件员 顺丰速运 95338正在为您派件",
          timestamp: "2018-05-10 07:32:00",
        },
        {
          content: "快件到达 [北京海淀育新小区营业点]",
          timestamp: "2018-04-11",
        },
        {
          content:
              "快件在[北京顺义集散中心]已装车,准备发往 [北京海淀育新小区营业点]",
          timestamp: "2018-05-10 02:03:00",
        },
        {
          content: "快件到达 [北京顺义集散中心]",
          timestamp: "2018-05-09 23:05:00",
        },
        {
          content: "快件在[北京宝胜营业点]已装车,准备发往 [北京顺义集散中心]",
          timestamp: "2018-05-09 21:21:00",
        },
        {
          content: "顺丰速运 已收取快件",
          timestamp: "2018-05-09 13:07:00",
        },
      ],
    };
  },
  created() {
    this.order();
  },
  methods: {
    async order() {
      const res = await getorderlist({
        pagenum: this.pagenum,
        pagesize: this.pagesize,
        query: this.query,
      });
      console.log(res);
      this.tableData = res.data.goods;
      this.total = res.data.total;
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.pagesize = val;
      this.order();
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.pagenum = val;
      this.order();
    },
    wuliu() {
      this.wuliudialogVisible = true;
    },
    async bianji(id) {
      console.log(id);
      const res1 = await getorderlistapi(id.order_id);
      if (res1.data.pay_status === "0") {
        res1.data.pay_status = "未付款";
      } else {
        res1.data.pay_status = "已付款";
      }
      this.dialogVisible = true;
      this.ruleForm = res1.data;
      this.id = id.order_id;
      // console.log(res1.data);
    },
    async submitForm() {
      const gai = await getorder(this.id, this.ruleForm);
      console.log(gai);
      this.order();
      this.dialogVisible = false;
      this.$message.success("修改成功");
    },
  },
};
</script>

<style scoped lang="less">
.el-breadcrumb {
  margin-bottom: 20px;
}
.c2 {
  margin-bottom: 20px;
}
</style>